<template>
  <van-cell-group id="Candid">
    <van-cell
      v-for="(item, index) in list"
      :key="index"
      :title="item.name"
      :value="item.avg_score | toFixed"
      :label="college_list[item.school - 1]">
    </van-cell>
  </van-cell-group>
</template>

<script>
  import {Cell, CellGroup, Icon, Dialog} from 'vant';

  export default {
    name: "FinalScore",
    components: {
      [Cell.name]: Cell,
      [CellGroup.name]: CellGroup,
      [Icon.name]: Icon,
      [Dialog.name]: Dialog,
    },
    props: ["candidStatus"],
    filters: {
      toFixed(value) {
        return value.toFixed(2);
      }
    },
    data() {
      return {
        list: [],
        college_list: [],
      }
    },
    methods: {
      getData() {
        let _this = this;
        let token = _this.getCookie("token");
        // 打分情况
        _this.$http.get(_this.apiUrl("user/selection/getFinalScore"), {
          headers: {
            'token': token,
            'sid': _this.$route.query.sid
          }
        }).then((res) => {
          console.log(res.data);
          _this.list = res.data.data;
        });
      },
      getCollege() {
        let _this = this;
        let token = _this.getCookie("token");
        _this.$http.get(_this.apiUrl("user/selection/getCollege"), {
          headers: {
            'token': token,
            'sid': _this.$route.query.sid
          }
        }).then((res) => {
          console.log(res.data);
          // console.log(_this.$route.query.sid);
          let college_list = res.data.data;
          for (let i = 0; i < college_list.length; i++) {
            _this.college_list.push(college_list[i].name);
          }
        });
      },
    },
    mounted() {
      let _this = this;
      _this.getData();
      _this.getCollege();
    },
    watch: {
      "candidStatus": function () {
        let _this = this;
        _this.getData();
      }
    }
  }
</script>
<style>
  #Candid .van-cell__title, #Candid .van-cell__value {
    flex: none;
  }

  #Candid .van-cell__title {
    width: 80%;
  }

  #Candid .van-cell__value {
    width: 20%;
  }
</style>
<style scoped>

</style>
